const G = {
	/*页面跳转*/
	navTo:function(url){
		uni.navigateTo({
			url
		});
	},
	/*
	 * 判断身份证
	 */
	card_validation:function(cardid){
		if(!(/^[1-9]{1}[0-9]{14}$|^[1-9]{1}[0-9]{16}([0-9]|[xX])$/.test(cardid))) {
			//mui.toast("身份证号有误，请重新输入");
			return false;
		} else {
			return true;
		}
	},
	/*
	 * 判断手机号
	 */
	phone_validation:function(phone) {
		if(!(/^1(3|4|5|7|8)\d{9}$/.test(phone))) {
			//mui.toast("手机号码有误，请重新输入");
			return false;
		} else {
			return true;
		}
	},
	/*
	 * 车牌判断
	 */
	plate_number_validation:function(str) {
		if(str.length == 7) {
			let express = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$/;
			if(!express.test(str)) {
				mui.toast("车牌号有误，请重新输入");
			} else {
				return true;
			}
		} else {
			//mui.toast("车牌号有误，请重新输入");
			return false;
		}
	},
	/*
	 * 判断是pc还是移动端
	 */
	gomatch:function() {
	    if ((navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i))) {
	        return "mobile";
	    }
	    else {
	        return "pc";
	    }
	            
	},
	/*
	 * 判断系统
	 */
	getxitong:function() {
	    let u = navigator.userAgent, app = navigator.appVersion;
	    let isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1;
	    let isIOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
	    if (isAndroid) {
	       return "android";
	    }
	    if (isIOS) {
		   return "ios";
	    }
	},
	/*
	 * 查看路径后面的参数（编码优化版）
	 */
	getrequest:function() {
		let url = location.search; //获取url中"?"符后的字串  
		let theRequest = new Object();
		if(url.indexOf("?") != -1) {
			let str = url.substr(1);
			strs = str.split("&");
			for(let i = 0; i < strs.length; i++) {
				theRequest[strs[i].split("=")[0]] = unescape(decodeURI(strs[i].split("=")[1]));
			}
		}
		return theRequest;
	},
	/*
	 * 验证非法字符
	 */
	checkStr:function(strTest) {
	     let pat = new RegExp("[^a-zA-Z0-9\_\u4e00-\u9fa5]", "i");
	     let strArr = strTest.split("");
	     for (let i = 0; i < strArr.length; i++) {
	         let str = strTest.charAt(i);
	         if (pat.test(strArr[i]) == true) {
	             strArr[i] = "()";
	             console.log("含有非法字符");
	             return false
	         }
	     }
	     return true
	},  
}

export default {
	G
}